const Base = require("./base");
module.exports = class MusicService extends Base {
  list(query) {
    const { page, size, type } = query;
    let sql = `SELECT COUNT(*) as total FROM music WHERE type='${type} AND status>0';
    SELECT * FROM music WHERE type='${type}' AND status>0 LIMIT ${(page - 1) * size},${size};`;
    return this.app.mysql
      .use("foindia")
      .query(sql)
      .then(res=> {
        const p = res[0][0][0] || {};
        return {
          pages: {
            ...p,
            size,
            page,
          },
          list: res[0][1] || []
        }
      });
  }
};
